home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: fastPath.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:40 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "disk.h"
- #include "thread.h"
- #include "semaphore.h"
- #include "latch.h"
- #include "link.h"
- #include "bf.h"
- #include "volume.h"
- #include "log.h"
- #include "lsn.h"
- #include "openlog.h"
- #include "threadstate.h"
- #include "thread_globals.h"
- #include "stat_globals.h"
- #include "msg_globals.h"
- #include "disk_funcs.h"
- #include "disk_globals.h"
- #include "../../diskproc/include/diskproc_extfuncs.h"
- #include "log_globals.h"
- #include "pool.h"
- #include "io_globals.h"
-
- #define CHECK_THREAD_ERROR \
- SM_ASSERT(LEVEL_3, (Active->error == esmNOERROR && \
- Active->errno == esmNOERROR) || \
- (Active->error != esmNOERROR && \
- Active->errno != esmNOERROR))
-
-
- /* the return value is
- * TRUE if all the i/o is done (by fast path),
- * FALSE if the remote process has to do the work
- */
- BOOL
- fastPath (
- VOLREC *volRec,
- DISKMSG *message
- )
-
- {
- typedef void (*PFVD)(DISKMSG *);
- PFVD func = (PFVD)0;
-
- switch( message->header.type ) {
- case OPEN_DISK:
- /* Special case:
- * This MUST be done both locally and remotely,
- * so we'll go ahead and do it, get the file
- * descriptor, and then act as if we didn't do
- * it locally. That way it'll be done remotely as well.
- */
- Active->error = Active->errno = 0;
- (void) openLocalDisk( message, volRec->volNameRec->volName.name );
- volRec->fd = Fd;
- CHECK_THREAD_ERROR;
- Active->errno = (int)message->header.params.out.errno;
- if ( FastPathOnly ) {
- return TRUE;
- } else {
- return FALSE; /* a lie for the server's normal operation */
- }
-
- case CLOSE_DISK:
- /*
- * Must be done both locally and remotely.
- */
- Fd = volRec->fd;
- Active->error = Active->errno = 0;
- (void) closeLocalDisk( message );
- volRec->fd = -1;
- CHECK_THREAD_ERROR;
- Active->errno = (int)message->header.params.out.errno;
- if ( FastPathOnly ) {
- return TRUE;
- } else {
- return FALSE; /* a lie for the server's normal operation */
- }
-
- case READ_BLOCK:
- func = readLocalDisk;
- break;
- case WRITE_BLOCK:
- func = writeLocalDisk;
- break;
- case DUMP_MON:
- func = dumpLocalProfiling;
- break;
- case FSYNC_DISK:
- func = fsyncLocalDisk;
- break;
- default:
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- break;
- }
- /*
- * Somewhat simplistic:
- * do only if activity is such that it's apropos,
- * namely, if all the activity is on one volume, or
- * if there's only one client.
- * TODO: Some day... figure out if there are any clients already
- * waiting to be select()ed, by looking at ReadMask & ~DiskMask.
- * (Keep in mind that they are BITVECs, not unsigned ints.)
- *
- * FastPathOnly is TRUE when : this is formatvol, and when
- * this is the server pre-mounting volumes (no clients yet).
- */
- if( FastPathOnly ||
- ( ( NumActiveClients <= 1 ) &&
- !(OpenLog.flags & LOG_CHECKPOINT_IN_PROGRESS) &&
- PreventFastPath == 0 ) ) {
-
- SM_ASSERT(LEVEL_1, (func != (PFVD)0) );
-
- /* do fast path */
- Fd = volRec->fd;
- Active->error = Active->errno = 0;
- (void) (*func)( message );
- CHECK_THREAD_ERROR;
- Active->errno = (int)message->header.params.out.errno;
- return TRUE;
- } else {
-
- /* remote i/o */
- Active->errno = (int)message->header.params.out.errno;
- return FALSE;
- }
- }
-